package com.coco.action;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.coco.base.BaseServlet;
import com.coco.model.Category;
import com.google.gson.Gson;

/**
 * Servlet implementation class CategoryServlet
 */
public class CategoryServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;

    public CategoryServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	protected void initCategory(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException {
		response.setContentType("text/json;charset=utf-8");
		List<Category> list = categoryServiceImpl.findAllCategory();
		Gson gson = new Gson();
		response.getWriter().write(gson.toJson(list));
		
	}

}
